package com.okami.java8.stream;

/**
 * @description:
 * @author: TanJingyu
 * @create: 2020-09-15 15:14
 **/
import static java.util.stream.IntStream.range;
public class Ranges {
    public static void main(String[] args) {
        // 传统方法:
        int result = 0;
        for (int i = 10; i < 20; i++) {
            result += i;
        }
        System.out.println(result);

        // for-in 循环:
        result = 0;
        for (int i : range(10, 20).toArray()) {
            result += i;
        }
        System.out.println(result);

        // 使用流:
        System.out.println(range(10, 20).sum());
    }
}
